clc; clear all;
H= 19e6;
Rz=6400e3;
Tobr=12*60*60;
Tmod=(Tobr/2);%vremia modelirovania
wobr=2*pi/Tobr;
c_light=3e8;
f_0=1602e6;%chastota
dt=5*60;
t=0:dt:Tmod;
rr=[0;Rz];
%vector potrebitelia
x=[0;Rz]; %koordinata potribitelia


D = nan(1 , length(t));
y_rv = nan(1 , length(t));



% for i=1:length(t)
rsv=(H+Rz)*...
    [cos(wobr*t);
    sin(wobr*t)];
%plot( [0 rsv(1)],[0 rsv(2)]);%'.'tochki
%xlim([-H-Rz;H+Rz])
%ylim([-Rz;H+Rz])
%axis equal
%pause (0.01);

rv=rsv-repmat(rr,1,length(t));
x_rv=rv(1,:);


y_rv=rv(2,:);%находим спутник над горизонтом.
D= sqrt(x_rv.^2+y_rv.^2);

%end

% figure;
% plot(t,D)
% xlabel('x,sec');
% ylabel('y,m');


V=diff(D)/dt;
%  figure;
%  plot(t(2:end),V)
%  xlabel('x,sec');
%  ylabel('V,m/s');
df = -(V/c_light)*f_0;


%    figure;
%  plot(t(2:end),df)
%  xlabel('x,sec');
%  ylabel('df,Hz');
 
 
ind = find(y_rv>0);%index prosto index
  
     figure;
     subplot(2,1,1)
  plot(t(2:end),df,t(ind),df(ind-1))
  xlabel('x,sec');
   ylabel('df,Hz');
 




     subplot(2,1,2)
hist(df,10)
xlabel('df,Hz');
        
